package com.holly.unit.deform.api.util;

import cn.hutool.extra.spring.SpringUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.holly.unit.system.api.OrganizationServiceApi;
import com.holly.unit.system.api.UserServiceApi;
import com.holly.unit.system.api.pojo.organization.HrOrganizationDTO;
import com.holly.unit.system.api.pojo.user.SysUserDTO;

import java.util.List;

/**
 * 类描述: 用户和部门操作
 *
 * @author fxr
 * @version 1.0.0
 * @date 2022/4/5 13:48
 */
public class UserOrDeptUtil {

    /***
     * 查询所有的用户 剔除被删除的用户
     * @return
     */
    public static List<JSONObject> queryAllUser() {
        UserServiceApi userServiceApi = SpringUtil.getBean(UserServiceApi.class);
        List<SysUserDTO> dtos = userServiceApi.queryAllUserList(null);
        return JSON.parseArray(JSON.toJSONString(dtos)).toJavaList(JSONObject.class);
    }

    /***
     * 查询并翻译出所有的部门信息
     * @return
     */
    public static List<JSONObject> queryAllDepart() {
        OrganizationServiceApi organizationServiceApi = SpringUtil.getBean(OrganizationServiceApi.class);
        List<HrOrganizationDTO> dtos = organizationServiceApi.orgList();
        return JSON.parseArray(JSON.toJSONString(dtos)).toJavaList(JSONObject.class);
    }
}
